<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UI元素状态伪类选择器-checked</title>
    <style>
        /* input 表单  :checked */
        form {
            border: 1px solid #ccc;
            padding: 20px;
            width: 300px;
            margin: 30px auto;
        }

        .wrapper {
            margin-bottom: 10px;
        }

        .box {
            display: inline-block;
            width: 20px;
            height: 20px;
            margin-right: 10px;
            position: relative;
            border: 2px solid orange;
            vertical-align: middle;
        }

        .box input {
            opacity: 0;
            position: absolute;
            top: 0;
            left: 0;
        }

        .box span {
            position: absolute;
            top: -10px;
            right: 3px;
            font-size: 30px;
            font-weight: bold;
            font-family: Arial;
            -webkit-transform: rotate(30deg);
            transform: rotate(30deg);
            color: orange;
        }


        /* 默认隐藏  [type="checkbox"]  属性选择器*/
        input+span {
            opacity: 0;
        }

        /* 选中的时候显示 :checked  */
        input:checked+span {
            opacity: 1;
        }
    </style>
</head>

<body>
    <input type="checkbox">

    <form action="#">
        <div class="wrapper">
            <div class="box">
                <input type="checkbox" checked id="usename" /><span>√</span>
            </div>
            <lable for="usename">我是选中状态</lable>
        </div>

        <div class="wrapper">
            <div class="box">
                <input type="checkbox" checked="checked"  id="usepwd" /><span>√</span>
            </div>
            <label for="usepwd">我是未选中状态</label>
        </div>
    </form>
</body>

</html>